package com.jay.lang.reflect.clazz;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import com.jay.lang.annotation.intf.MyAnnotation1;

public class ConstructorCls {
	public static void main(String[] args) throws InstantiationException,
			IllegalAccessException, IllegalArgumentException,
			InvocationTargetException {
		Constructor<?>[] cs1 = ConstructorCls.class.getConstructors();
		for (Constructor<?> c : cs1) {
			System.out.println(c.getName());
			System.out.println(c.getModifiers());
			System.out.println(c.isAccessible());
			System.out.println(c.isAnnotationPresent(MyAnnotation1.class));
			System.out.println(c.isSynthetic());
			System.out.println(c.isVarArgs());
			System.out.println(c.toGenericString());
			System.out.println(c.getAnnotations());
			System.out.println(c.getClass());
			System.out.println(c.getDeclaringClass());
			System.out.println(c.getExceptionTypes());
			System.out.println(c.getParameterTypes());
			c.newInstance(null);
		}
		System.out.println("---------------------");
		Constructor<?>[] cs2 = A.class.getDeclaredConstructors();
		for (Constructor<?> c : cs2) {
			System.out.println(c.getName());
			System.out.println(c.getModifiers());
			System.out.println(c.isAccessible());
			System.out.println(c.isAnnotationPresent(MyAnnotation1.class));
			System.out.println(c.isSynthetic());
			System.out.println(c.isVarArgs());
			System.out.println(c.toGenericString());
			System.out.println(c.getAnnotations());
			System.out.println(c.getClass());
			System.out.println(c.getDeclaringClass());
			System.out.println(c.getExceptionTypes());
			System.out.println(c.getParameterTypes());
		}
		Constructor c = cs2[0];
		c.setAccessible(true);
		c.newInstance(Integer.valueOf(12));

		c = cs2[1];
		// c.setAccessible(true);
		c.newInstance(Integer.valueOf(12), "xxx");
	}
}

class A {
	public A() {
	}

	private A(int i) {

	}

	protected A(int i, String s) {

	}
}